#!/usr/bin/perl -w
#Importing the manuscript data into the database. Import scripts have the same basename (plus '.pl' extension) as the directory containing the manuscript data

use strict;
use warnings;
use utf8;
use open ':encoding(utf8)';
use XML::LibXML;

open EXTERNALS, "externals.txt"
  or die "externals.txt not found";

while(<EXTERNALS>){
	chomp;
	next if /^\s*(#|$)/;
	my($dir, $url) = split(/\s+/, $_, 2);
	
	if(!-d $dir){
		warn " - External directory '$dir' doesn't exist.\n";
		next;
	}
	if(!-f "$dir.pl"){
		warn " - Import script called '$dir.pl' doesn't exist\n";
		next;
	}
	
	print "- Running import script $dir.pl\n";
	require "$dir.pl";
}

1;